package com.ericcson.innerportalapp;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class EmergencyFragment extends Fragment {

	private EmergencyArrayAdapter emergencyArrayAdapter;
	private View rootView;
	private int id;
	private ArrayList<String> names;
	private ArrayList<ArrayList<Emergency>> values;
	public static final String ARG_SECTION_NUMBER = "section_number";
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		rootView = inflater.inflate(R.layout.fragment_emergency_dummy,
				container, false);
		ListView mainListView = (ListView)  rootView.findViewById( R.id.listView1 );  

		id = getArguments().getInt(ARG_SECTION_NUMBER);
		names = (ArrayList<String>) getArguments().getSerializable("namesArray");
		values = (ArrayList<ArrayList<Emergency>>) getArguments().getSerializable("valuesArray");
		
		for (int i = 0; i < names.size(); i++) {
			if(id == i){
				emergencyArrayAdapter = new EmergencyArrayAdapter(this.getActivity(), R.layout.emergency_list_item, values.get(i));
			}
		}

	    mainListView.setAdapter(emergencyArrayAdapter); 
		return rootView;
		
	}
}
